<template>
	<s-layout>
		<view class="new-create-activity-container">
			<!-- 新版顶部导航 -->
			<view class="new-nav-bar" style="margin-top: 20px;">
				<view class="new-nav-back-button" @click="goBack">
					<text class="new-nav-icon">‹</text>
				</view>
				<text class="new-nav-main-title">发起新活动</text>
			</view>
		
			<!-- 核心内容区域 -->
			<scroll-view scroll-y class="new-main-content-scroll">
				<!-- 顶部欢迎与快捷操作 -->
				<view class="new-welcome-banner">
					<text class="new-welcome-greeting">你好！准备好策划一场精彩活动了吗？</text>
					<text class="new-welcome-subtitle">从选择活动类型与方式开始</text>
				</view>
		
				<view class="new-quick-access-grid">
					<view class="new-access-card drafts-card" @click="caogao">
						<text class="new-card-icon">📄</text>
						<view class="new-card-text-content">
							<text class="new-card-main-text">我的草稿</text>
							<text class="new-card-sub-text">查看已保存的活动</text>
						</view>
						<text class="new-card-arrow">›</text>
					</view>
					<view class="new-access-card templates-card">
						<text class="new-card-icon">💡</text>
						<view class="new-card-text-content">
							<text class="new-card-main-text">从模板创建</text>
							<text class="new-card-sub-text">使用预设模板快速发起</text>
						</view>
						<text class="new-card-arrow">›</text>
					</view>
				</view>
		
				<!-- 活动类型选择 -->
				<view class="new-selection-group">
					<view class="new-group-header">
						<text class="new-header-icon">🎯</text>
						<text class="new-header-main-text">活动类型</text>
						<text class="new-header-sub-text">请选择一个主要类型</text>
					</view>
					<view class="new-options-container type-options">
						<view class="new-option-item" :class="{ 'selected': selectedType === 0 }"
							@tap="selectActivityType(0)">
							<text class="new-item-icon">📖</text>
							<view class="new-item-details">
								<text class="new-item-title">书籍讨论</text>
								<text class="new-item-description">围绕书籍、主题书会、换书等</text>
							</view>
							<view class="new-item-checkmark" v-if="selectedType === 0">✓</view>
						</view>
						<view class="new-option-item" :class="{ 'selected': selectedType === 1 }"
							@tap="selectActivityType(1)">
							<text class="new-item-icon">🎬</text>
							<view class="new-item-details">
								<text class="new-item-title">影视研讨</text>
								<text class="new-item-description">电影、剧集、纪录片等分享</text>
							</view>
							<view class="new-item-checkmark" v-if="selectedType === 1">✓</view>
						</view>
						<view class="new-option-item" :class="{ 'selected': selectedType === 2 }"
							@tap="selectActivityType(2)">
							<text class="new-item-icon">💬</text>
							<view class="new-item-details">
								<text class="new-item-title">话题交流</text>
								<text class="new-item-description">行业、经验、兴趣等各类话题</text>
							</view>
							<view class="new-item-checkmark" v-if="selectedType === 2">✓</view>
						</view>
					</view>
				</view>
		
				<!-- 活动方式选择 -->
				<view class="new-selection-group">
					<view class="new-group-header">
						<text class="new-header-icon">🌍</text>
						<text class="new-header-main-text">活动方式</text>
						<text class="new-header-sub-text">选择线上或线下</text>
					</view>
					<view class="new-options-container mode-options">
						<view class="new-option-item" :class="{ 'selected': selectedMode === 3 }"
							@tap="selectActivityMode(3)">
							<text class="new-item-icon">🏠</text>
							<view class="new-item-details">
								<text class="new-item-title">线下活动</text>
								<text class="new-item-description">同城见面，真实互动</text>
							</view>
							<view class="new-item-checkmark" v-if="selectedMode === 3">✓</view>
						</view>
						<view class="new-option-item" :class="{ 'selected': selectedMode === 4 }"
							@tap="selectActivityMode(4)">
							<text class="new-item-icon">💻</text>
							<view class="new-item-details">
								<text class="new-item-title">线上活动</text>
								<text class="new-item-description">网络连接，跨越地域</text>
							</view>
							<view class="new-item-checkmark" v-if="selectedMode === 4">✓</view>
						</view>
					</view>
				</view>
			</scroll-view>
		
			<!-- 新版底部操作栏 -->
			<view class="new-bottom-action-bar">
				<button class="new-confirm-button" :class="{ 'disabled': !isSelectionComplete }" @tap="confirmSelection"
					:disabled="!isSelectionComplete">
					<text class="new-button-text">下一步，完善信息</text>
					<text class="new-button-arrow-icon" v-if="isSelectionComplete">→</text>
				</button>
				<text class="new-action-hint" v-if="!isSelectionComplete">请先选择活动类型和方式</text>
			</view>
		</view>
	</s-layout>
</template>

<script>
export default {
	data() {
		return {
			selectedType: null, // 0: 书籍讨论, 1: 影视讨论, 2: 话题讨论
			selectedMode: null, // 3: 线下活动, 4: 线上活动
		}
	},
	computed: {
		isSelectionComplete() {
			return this.selectedType !== null && this.selectedMode !== null;
		}
	},
	methods: {
		selectActivityType(typeIndex) {
			if (this.selectedType === typeIndex) {
				this.selectedType = null;
			} else {
				this.selectedType = typeIndex;
			}
		},
		selectActivityMode(modeIndex) {
			if (this.selectedMode === modeIndex) {
				this.selectedMode = null;
			} else {
				this.selectedMode = modeIndex;
			}
		},
		confirmSelection() {
			if (!this.isSelectionComplete) return;

			let typeParam = '';
			let modeParam = '';

			switch (this.selectedType) {
				case 0: typeParam = 'book'; break;
				case 1: typeParam = 'movie'; break;
				case 2: typeParam = 'topic'; break;
			}

			switch (this.selectedMode) {
				case 3: modeParam = 'offline'; break;
				case 4: modeParam = 'online'; break;
			}

			uni.navigateTo({
				url: `/pages/book/creatActivity/promise?type=${typeParam}&mode=${modeParam}&typeIndex=${this.selectedType}&modeIndex=${this.selectedMode}`
			});
		},
		caogao() {
			uni.navigateTo({
				url: '/pages/book/creatActivity/caogao'
			});
		},
		goBack() {
			uni.navigateBack();
		}
	}
}
</script>

<style lang="scss">
$new-theme-primary: #E53935; // 红色主题
$new-theme-accent: #FFB300; // 点缀色（橙黄）
$new-theme-bg: #FFF5F5; // 浅红背景
$new-theme-card: #fff;
$new-theme-border: #F8BBD0; // 浅粉边框
$new-theme-shadow: 0 4rpx 16rpx rgba(229, 57, 53, 0.10);
$new-theme-black: #222;
$new-theme-gray: #888;
$new-theme-white: #fff;
$new-theme-radius: 24rpx;
$new-theme-transition: all 0.25s cubic-bezier(.4, 0, .2, 1);

.new-create-activity-container {
	background-color: $new-theme-bg;
	color: $new-theme-black;
	min-height: 100vh;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
	display: flex;
	flex-direction: column;
}

.new-nav-bar {
	display: flex;
	align-items: center;
	padding: 24rpx 30rpx;
	background-color: $new-theme-card;
	box-shadow: $new-theme-shadow;
	position: sticky;
	top: 0;
	z-index: 1000;
	border-radius: 0 0 $new-theme-radius $new-theme-radius;
}

.new-nav-back-button {
	width: 70rpx;
	height: 70rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: $new-theme-transition;

	&:active {
		background-color: lighten($new-theme-primary, 45%);
	}
}

.new-nav-icon,
.new-nav-main-title {
	color: $new-theme-black;
}

.new-nav-main-title {
	flex-grow: 1;
	text-align: center;
	font-size: 36rpx;
	font-weight: 600;
	margin-right: 70rpx; // 为返回按钮留出空间，保持标题居中
}

.new-main-content-scroll {
	flex-grow: 1;
	padding: 0 30rpx 180rpx; // 底部留出操作栏空间
}

.new-welcome-banner {
	padding: 48rpx 24rpx 40rpx 24rpx;
	margin: 30rpx 0;
	background-image: linear-gradient(135deg, $new-theme-primary 0%, $new-theme-accent 100%);
	border-radius: $new-theme-radius;
	text-align: center;
	color: $new-theme-white;
	box-shadow: $new-theme-shadow;
}

.new-welcome-greeting {
	display: block;
	font-size: 38rpx;
	font-weight: 700;
	margin-bottom: 10rpx;
}

.new-welcome-subtitle {
	display: block;
	font-size: 28rpx;
	opacity: 0.9;
}

.new-quick-access-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 32rpx;
	margin-bottom: 48rpx;
}

.new-access-card {
	background-color: #ffffff;
	border-radius: $new-theme-radius;
	padding: 30rpx;
	display: flex;
	align-items: center;
	box-shadow: $new-theme-shadow;
	transition: $new-theme-transition;

	&:active {
		transform: scale(0.97);
		box-shadow: 0 2rpx 8rpx rgba(229, 57, 53, 0.08);
	}
}

.drafts-card .new-card-icon {
	background-color: lighten($new-theme-primary, 45%);
	color: $new-theme-primary;
}

.templates-card .new-card-icon {
	background-color: lighten($new-theme-accent, 45%);
	color: $new-theme-accent;
}

.new-card-icon {
	font-size: 40rpx;
	width: 80rpx;
	height: 80rpx;
	border-radius: 16rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: 20rpx;
	background-color: lighten($new-theme-primary, 40%);
}

.new-card-text-content {
	flex-grow: 1;
}

.new-card-main-text,
.new-card-sub-text {
	color: $new-theme-black;
}

.new-card-main-text {
	display: block;
	font-size: 30rpx;
	font-weight: 600;
	margin-bottom: 4rpx;
}

.new-card-sub-text {
	display: block;
	font-size: 24rpx;
}

.new-card-arrow {
	font-size: 32rpx;
	color: #adb5bd;
}

.new-selection-group {
	margin-bottom: 48rpx;
}

.new-group-header {
	display: flex;
	align-items: center;
	margin-bottom: 28rpx;
}

.new-header-icon {
	font-size: 36rpx;
	margin-right: 16rpx;
}

.new-header-main-text,
.new-header-sub-text {
	color: $new-theme-black;
}

.new-header-main-text {
	font-size: 34rpx;
	font-weight: 700;
	margin-right: 12rpx;
}

.new-header-sub-text {
	font-size: 26rpx;
}

.new-options-container {
	display: flex;
	flex-direction: column;
	gap: 28rpx;
}

.new-option-item {
	background-color: #ffffff;
	border-radius: $new-theme-radius;
	padding: 28rpx;
	display: flex;
	align-items: center;
	border: 2px solid transparent;
	box-shadow: $new-theme-shadow;
	transition: $new-theme-transition;

	&.selected {
		border-color: $new-theme-primary;
		background: linear-gradient(90deg, lighten($new-theme-primary, 45%) 0%, lighten($new-theme-accent, 45%) 100%);
		box-shadow: 0 8rpx 24rpx rgba(229, 57, 53, 0.13);
	}

	&:active {
		transform: scale(0.98);
	}
}

.type-options .new-option-item.selected {
	border-color: $new-theme-primary;
	background-color: lighten($new-theme-primary, 45%);
}

.mode-options .new-option-item.selected {
	border-color: $new-theme-accent;
	background-color: lighten($new-theme-accent, 45%);
}

.new-item-icon {
	font-size: 48rpx;
	width: 80rpx;
	height: 80rpx;
	border-radius: 12rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: 24rpx;
	background-color: #e9ecef;
	color: #495057;
}

.new-item-details {
	flex-grow: 1;
}

.new-item-title,
.new-item-description {
	color: $new-theme-black;
}

.new-item-title {
	display: block;
	font-size: 32rpx;
	font-weight: 600;
	margin-bottom: 6rpx;
}

.new-item-description {
	display: block;
	font-size: 26rpx;
	line-height: 1.4;
}

.new-item-checkmark {
	color: $new-theme-primary;
	font-size: 40rpx;
	font-weight: bold;
}

.new-bottom-action-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 24rpx 30rpx calc(24rpx + env(safe-area-inset-bottom));
	background-color: rgba(255, 255, 255, 0.98);
	backdrop-filter: blur(10px);
	border-top: 1px solid $new-theme-border;
	box-shadow: 0 -2rpx 8rpx rgba(229, 57, 53, 0.04);
	display: flex;
	flex-direction: column;
	align-items: center;
	z-index: 999;
}

.new-confirm-button {
	width: 100%;
	height: 96rpx;
	background-image: linear-gradient(to right, $new-theme-primary 0%, darken($new-theme-primary, 10%) 100%);
	color: $new-theme-white;
	font-size: 32rpx;
	font-weight: 600;
	border-radius: 48rpx;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8rpx 24rpx rgba(229, 57, 53, 0.18);
	transition: $new-theme-transition;

	&.disabled {
		background-image: none;
		background-color: $new-theme-gray;
		color: $new-theme-white;
		box-shadow: none;
	}

	&:active:not(.disabled) {
		transform: translateY(2rpx);
		box-shadow: 0 4rpx 10rpx rgba(229, 57, 53, 0.12);
	}
}

.new-button-text {
	margin-right: 10rpx;
}

.new-button-arrow-icon {
	font-size: 30rpx;
}

.new-action-hint {
	font-size: 26rpx;
	color: #6c757d;
	margin-top: 16rpx;
}
</style>
